/**
 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

bool IsDynamicLanguage([[maybe_unused]] panda::panda_file::SourceLang lang)
{
% Common::plugins.each_value do |plugin_opts|
% next unless plugin_opts["language_config"]
% next unless plugin_opts["language_config"]["lang_type"]
    if (lang == <%= plugin_opts["lang_enum"] %>) {
        return <%= plugin_opts["language_config"]["lang_type"] == "dynamic" %>; //NOLINT(readability-simplify-boolean-expr)
    }
% end

    return false;
}

std::optional<panda::panda_file::SourceLang> LanguageFromString([[maybe_unused]] std::string_view lang)
{
%   Common::plugins.each_value do |plugin_opts|
%     next unless plugin_opts["directive_name"]
    if (lang == "<%= plugin_opts["directive_name"] %>") {
        return <%= plugin_opts["lang_enum"] %>;
    }
%   end

    if (lang == "PandaAssembly") {
        return panda::panda_file::SourceLang::PANDA_ASSEMBLY;
    }

    return {};
}

const char *LanguageToString([[maybe_unused]] panda::panda_file::SourceLang lang)
{
%   Common::plugins.each_value do |plugin_opts|
%     next unless plugin_opts["directive_name"]
    if (lang == <%= plugin_opts["lang_enum"] %>) {
        return "<%= plugin_opts["directive_name"] %>";
    }
%   end

    return "PandaAssembly";
}

const char *GetCtorName([[maybe_unused]] panda::panda_file::SourceLang lang)
{
%   Common::plugins.each_value do |plugin_opts|
%     next unless plugin_opts["ctor_name"]
    if (lang == <%= plugin_opts["lang_enum"] %>) {
        return "<%= plugin_opts["ctor_name"] %>";
    }
%   end

    return ".ctor";
}

const char *GetCctorName([[maybe_unused]] panda::panda_file::SourceLang lang)
{
%   Common::plugins.each_value do |plugin_opts|
%     next unless plugin_opts["cctor_name"]
    if (lang == <%= plugin_opts["lang_enum"] %>) {
        return "<%= plugin_opts["cctor_name"] %>";
    }
%   end

    return ".cctor";
}

const char *GetStringClassDescriptor([[maybe_unused]] panda::panda_file::SourceLang lang)
{
%   Common::plugins.each do |plugin_lang, plugin_opts|
%     next unless plugin_opts["string_class_descriptor"]
    if (lang == <%= plugin_opts["lang_enum"] %>) {
        return "<%= plugin_opts["string_class_descriptor"] %>";
    }
%   end

    return "Lpanda/String;";
}
